<?php
namespace Store\Controller;
class IndexController extends CommonController {
    
    public function index(){
        $userGroup = getUserGroup(STORE_ID);
        $user = M('User')->where('user_id = ' . USER_ID)->find();
        $this->assign('group', $userGroup);
        $this->assign('user', $user);
        $this->display();
    }
    
    /**
     * @数据
     *
     * @param void
     * @return json
     */
    public function dashboard(){
        $now = time();
        $week = $now - 86400 * 7;
        $month = $now - 86400 * 30;
        
//        $where = array( 'store_id' => STORE_ID );
//        $data['member_count'] = M('Member')->where($where)->count();
//
//        $where = array( 'store_id' => STORE_ID, 'create_time' => array('between', array( $week, $now)));
//        $data['week_add_member'] = M('Member')->where($where)->count();
//
//        $where = array( 'store_id' => STORE_ID, 'create_time' => array('between', array( $month, $now)));
//        $data['month_add_member'] = M('Member')->where($where)->count();
//
//
//        $where = array( 'status' => 1 );
//        $data['goods_count'] = M('Goods')->where($where)->count();
//
//        $where = array( 'store_id' => STORE_ID );
//        $data['order_count'] = M('Order')->where($where)->count();
//
        $where = array( 'store_id' => STORE_ID, 'create_time' => array('between', array( $week, $now)));
        $data['goods_count'] = M('Order')->where($where)->count();
//
//        $where = array( 'store_id' => STORE_ID, 'create_time' => array('between', array( $month, $now)));
//        $data['month_add_order'] = M('Order')->where($where)->count();
//
//        $where = array( 'store_id' => STORE_ID, 'order_state' => 4 );
//        $order = M('Order')->field('SUM(order_amount) AS amount')->where($where)->find();
//        $data['order_amount'] = $order['amount'];
//
//        $data['order_progressing'] = M('Order')->where('(order_state = 1 OR order_state = 2 OR order_state = 3) AND store_id = ' . STORE_ID)->count();
//        $data['order_payment'] = M('Order')->where('order_state = 1 AND store_id = ' . STORE_ID)->count();
//        $data['order_delivery'] = M('Order')->where('order_state = 2 AND store_id = ' . STORE_ID)->count();
        exit(json_encode($data));
    }
     

}